<?php
/**
 * Created by dutuwang.net
 * User: adophper <hello@adophper.com>
 * Date: 2018/4/17
 * Time: 11:04
 */

use \yii\helpers\Html;
$this->title = Yii::t('frontend', 'exhibition_compare_page');

$list = array(
    'title' => '展会名称',
    'time' => '展会时间',
    'hall_title' => '举办展馆',
    'city' => '展会地点',
    'score' => '综合点评',
    'sponsor' => '主办机构',
    'undertook' => '承办机构',
    'area' => '展会面积',
    'build_number' => '搭建数量',
    'website' => '展会官网',
    'business_number' => '展商数量',
    'business_data' => '展商构成',
    'audience_number' => '观众数量',
    'audience_data' => '观众构成',
    'exhibitor' => '知名展商',
);
?>
<?=Html::cssFile('/static/frontend/css/contrast.css')?>
<?=Html::jsFile('/static/common/js/Chart.min.js')?>
<div class="page">
    <div class="head_banner_bg" style="background-color: #414141;">
        <div class="contBox">
            <div class="news-page-banner">
                <h2>展会数据对比</h2>
            </div>
        </div>
    </div>
    <div class="contBox news-page-content">
        <div class="detailBox_title fbox">
            <ol class="fbox">
                <li class="fl"><a href="/">首页</a></li>
                <li class="fl">》</li>
                <li class="fl"><a href="<?=Yii::$app->urlManager->createUrl(['zhanhui/index'])?>">找展会</a></li>
                <li class="fl">》</li>
                <li class="fl">展会数据对比</li>
            </ol>
            <div class="fr detailBox_title_search exhibition_search">
                <input type="text" placeholder="请输入查找内容" />
                <i class="btn_red iconfont" data-url="<?=Yii::$app->urlManager->createUrl(['zhanhui/index', 'starttime' => ''])?>">&#xe643;</i>
            </div>
        </div>
        <div class="contrast_min">
            <p class="t_red contrast_tips">*备注：展后数据部分均为上届展会数据</p>
            <table class="table contrast_list">
                <?php
                $i = 1;
                foreach ($list as $k => $v) {
                ?>
                <tr class="<?=$i%2==1?'gray_are':'white_are'?>">
                    <td class="contrast_item_lable <?=$k?>">
                        <?=$v?>
                    </td>
                    <?php
                    if (!empty($data)) {
                        foreach ($data as $val) {
                    ?>
                    <td class="contrast_item_info <?=$k?>">
                        <?php
                        if ($k == 'title') {
                        ?>
                        <a href="<?=Yii::$app->urlManager->createUrl(['zhanhui/detail', 'id' => $val['id']])?>"><?=$val['title']?></a>
                        <?php
                        } elseif ($k == 'time') {
                        ?>
                        <?=date('Y-m-d', $val['starttime'])?><?=Yii::t('frontend', 'to')?><?=date('Y-m-d', $val['endtime'])?>
                        <?php
                        } elseif ($k == 'score') {
                        ?>
                        <div class=" rating-stars" title="<?=$val['score']?>">
                            <span class="empty-stars">
                                <span class="star"><i class="glyphicon glyphicon-star"></i></span>
                                <span class="star"><i class="glyphicon glyphicon-star"></i></span>
                                <span class="star"><i class="glyphicon glyphicon-star"></i></span>
                                <span class="star"><i class="glyphicon glyphicon-star"></i></span>
                                <span class="star"><i class="glyphicon glyphicon-star"></i></span>
                            </span>
                            <span class="filled-stars" style="width: <?=$val['score']*20?>%;">
                                <span class="star"><i class="glyphicon glyphicon-star"></i></span>
                                <span class="star"><i class="glyphicon glyphicon-star"></i></span>
                                <span class="star"><i class="glyphicon glyphicon-star"></i></span>
                                <span class="star"><i class="glyphicon glyphicon-star"></i></span>
                                <span class="star"><i class="glyphicon glyphicon-star"></i></span>
                            </span>
                        </div>
                        <?php
                        }elseif ($k == 'area'){
                        ?>
                            <?=number_format($val['area'])?>平方米
                        <?php
                        }elseif ($k == 'audience_number'){
                        ?>
                            <?=$val['audience_number']?>人
                        <?php
                        }elseif ($k == 'website'){
                        ?>
                            <a href="<?=!empty($val['website'])?$val['website']:''?>" target="_blank"><?=$val['website']?></a>
                        <?php
                        }
                        elseif ($k == 'business_data'){
                        ?>
                        <div class="chart" id="pieChartAudience"></div>
                        <script>
                            getAjaxPage('<?=Yii::$app->urlManager->createUrl(['/zhanhui/get-business', 'exhibition_id' => $val['id']])?>', {}, 'pieChartBusiness');
                        </script>
                        <?php
                        }elseif ($k == 'audience_data'){
                        ?>
                        <div class="chart" id="pieChartAudience"></div>
                        <script>
                        getAjaxPage('<?=Yii::$app->urlManager->createUrl(['/zhanhui/get-audience', 'exhibition_id' => $val['id']])?>', {}, 'pieChartAudience');
                        </script>
                        <?php
                        }else{
                        ?>
                        <?=isset($val[$k]) ? $val[$k] : ''?>
                        <?php
                        }
                        ?>
                    </td>
                    <?php
                        }
                    }
                    ?>
                </tr>
                <?php
                    $i++;
                }
                ?>
            </table>
        </div>
    </div>
</div>
